<?php
namespace app\model;

use app\model\BaseModel;
use app\model\SystemInfo;

class SystemGroup extends BaseModel{
    // 获取所有的设置分组信息
    public function getAllSettingGroups(){
        return $this->field(['id','name','sort'])->where('state',1)->order('sort','desc')->select();
    }
    // 获取分组及分组下的设置数据内容 返回合理的数据内容
    public function getSettingArray(){
        $select = $this->getAllSettingGroups();
        $sysHandle = new SystemInfo();
        foreach($select as $one){
            $groupId = $one['id'];
            $item = $sysHandle->where('system_group_id',$groupId)->select();
            $one['children'] = $item;
        }
        return $select;
    }
}